<!-- theme-mode.vue - 主题模式切换 -->
<template>
  <div class="drawer-item">
    <div class="drawer-item-header">
      <el-icon><Moon /></el-icon>
      <span>主题模式</span>
    </div>
    
    <div class="theme-mode-options">
      <div 
        v-for="option in themeModeOptions"
        :key="option.value"
        class="theme-mode-option"
        :class="{ 'is-active': themeMode === option.value }"
        @click="handleModeChange(option.value)"
      >
        <el-icon class="option-icon">
          <component :is="getModeIcon(option.icon)" />
        </el-icon>
        <span class="option-label">{{ option.label }}</span>
        <el-icon v-if="themeMode === option.value" class="check-icon" color="var(--el-color-primary)">
          <Select />
        </el-icon>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useTheme } from '@/composables/useTheme.js'
import { Moon, Sunny, Monitor, Select } from '@element-plus/icons-vue'

const {
  themeMode,
  themeModeOptions,
  setThemeMode
} = useTheme()

function handleModeChange(mode) {
  setThemeMode(mode)
}

function getModeIcon(iconName) {
  const iconMap = {
    'sun': Sunny,
    'moon': Moon,
    'computer': Monitor
  }
  return iconMap[iconName] || Sunny
}
</script>

<style lang="scss" scoped>
.theme-mode-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.theme-mode-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--el-border-color-light);
  background: var(--el-bg-color);
  cursor: pointer;
  transition: all 0.3s;
  
  &:hover {
    border-color: var(--el-color-primary);
    background: var(--el-color-primary-light-9);
  }
  
  &.is-active {
    border-color: var(--el-color-primary);
    background: var(--el-color-primary-light-9);
  }
  
  .option-icon {
    font-size: 18px;
    color: var(--el-text-color-primary);
  }
  
  .option-label {
    flex: 1;
    font-size: 14px;
    color: var(--el-text-color-primary);
  }
  
  .check-icon {
    font-size: 16px;
  }
}
</style>

